<template>
    <div class="pages-tables " id="pages-tables">
        <div class="rolling-table meal-table" ref="tableBox">
			<scroll-view :scroll-top="scrollTop" scroll-y="true" class="scroll-Y" scroll-x="true">
			      <table class="table" id="table" cellpadding="0" cellspacing="0" ref="rollingTable">
			        <tr v-for="(x,i) in xList" :key="i">
			            <th class="rows" :class="{'cross': index == 0 && i == 0}" v-for="(it,index) in x" :key="index" :colspan="it.colspan" :rowspan="it.rowspan">{{it.name}}</th>
			        </tr>
			        <tr v-for="(item,j) in yList" :key="j + 'a'">
			            <template v-for="(x, xKey) in xField" >
                            <template v-for="(item_,yKey) in item">
                                <td :key="xKey+yKey" v-if="x === yKey" :class="{'cols': yKey == xField[0] || yKey == xField[1]}">
                                    {{ yList[j][yKey] }}
                                </td>
                            </template>
                        </template>
			          </tr>
			          <tr></tr>
			      </table>              
			</scroll-view>
        </div>
    </div>
</template>
<script>
export default {
	props:{
		xList:{
			type: Array,
			default(){
				return []
			}
		},
		xField:{
			type: Array,
			default(){
				return []
			}
		},
		yList:{
			type: Array,
			default(){
				return []
			}
		},
	},
    data() {
        return {
            // maxHeight:'100%',
			scrollTop: 0,
			old: {
			    scrollTop: 0
			},
            scroll: {
                scroller: null
            }
        }
    },
    mounted() {
        // this.maxHeight = window.screen.height
        //this.scroll.scroller = createIScroller(".meal-table");
        // addWaterMarker(document.getElementById('watermark'))
    },
    beforeDestroy() {
      //destroyScroller();
    }
}

</script>
<style lang="scss" scoped>
.pages-tables {
  -webkit-overflow-scrolling: touch; // ios滑动顺畅
  position: relative;
}
.rolling-table {
    height: 100%;
    font-size: 2.4rem;
    color: #86939a;
    background-color: #fff;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    position: relative;
    top: 0;
    overflow: hidden;
  }
.rows {
    position: relative;
    z-index: 3;
}
.cross {
    position: relative;
    z-index: 5;
}
table td {
  border: 0.1rem solid #EEEEEE;
  font-size: 2.4rem;
  background: #fff;
}
::-webkit-scrollbar {
    display: none;
}
.table {
  border-collapse: collapse; //去掉重复的border
  color: #86939e;
  font-size: 2.4rem;
  border: 0.1rem solid #EEEEEE;
  height: auto;
  text-align: center;
  width: 100%;
  td {
    border-bottom: 0.1rem solid #EEEEEE;
    white-space: nowrap;
    height: 6rem;
    line-height: 6rem;
    padding: 0 1rem;
  }
  th {
    color: #43484d;
    white-space: nowrap;
    height: 6rem;
    line-height: 6rem;
    padding: 0rem 2rem;
    background-color: #f3f4f6;
    font-weight: normal;
    padding-bottom: 0;
    padding-top: 0;
    border: 0.1rem solid #EEEEEE;
  }
}
tr{
    position: relative;
    background-color: #fff;
}
</style>